﻿@model ShipmentModel
@{    
    //page title
    ViewBag.Title = T("Admin.Orders.Shipments.ViewDetails").Text;
}
@using (Html.BeginForm())
{
    <script type="text/javascript">
        $(document).ready(function () {
            toggleShippedDate(false);
            toggleDeliveryDate(false);
        });

        function toggleShippedDate(editmode) {
            if (editmode) {
                $('#lblShippedDate').hide();
                $('#divShippedDate').show();
                $('#btnEditShippedDate').hide();
                $('#btnSaveShippedDate').show();
                $('#btnCancelShippedDate').show();
            }
            else {
                $('#lblShippedDate').show();
                $('#divShippedDate').hide();
                $('#btnEditShippedDate').show();
                $('#btnSaveShippedDate').hide();
                $('#btnCancelShippedDate').hide();
            }
        }

        function toggleDeliveryDate(editmode) {
            if (editmode) {
                $('#lblDeliveryDate').hide();
                $('#divDeliveryDate').show();
                $('#btnEditDeliveryDate').hide();
                $('#btnSaveDeliveryDate').show();
                $('#btnCancelDeliveryDate').show();
            }
            else {
                $('#lblDeliveryDate').show();
                $('#divDeliveryDate').hide();
                $('#btnEditDeliveryDate').show();
                $('#btnSaveDeliveryDate').hide();
                $('#btnCancelDeliveryDate').hide();
            }
        }
    </script>
    <div class="section-header">
        <div class="title">
            <img src="@Url.Content("~/Administration/Content/images/ico-sales.png")" alt="" />
            @T("Admin.Orders.Shipments.ViewDetails") - @Model.Id @Html.ActionLink("(" + T("Admin.Orders.Shipments.BackToOrder") + ")", "Edit", new { id = Model.OrderId })
        </div>
        <div class="options">
            <a href="@Url.Action("PdfPackagingSlip", new { shipmentId = Model.Id })" class="t-button">@T("Admin.Orders.Shipments.PrintPackagingSlip")</a>
            <span id="shipment-delete" class="t-button">@T("Admin.Common.Delete")</span>
        </div>
    </div>
    @Html.ValidationSummary(false)
    <table class="adminContent">
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.TrackingNumber):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.TrackingNumber)
                <input type="submit" name="settrackingnumber" value="@T("Admin.Orders.Shipments.TrackingNumber.Button")" id="settrackingnumber" class="adminButton" />
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.TotalWeight):
            </td>
            <td class="adminData">
                @Model.TotalWeight
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.ShippedDate):
            </td>
            <td class="adminData">
                <span id="lblShippedDate">@Model.ShippedDate</span>
                @if (Model.CanShip)
                {
                    <input type="submit" name="setasshipped" value="@T("Admin.Orders.Shipments.ShippedDate.Button")" id="setasshipped" class="adminButton" />
                }
                @if (Model.ShippedDateUtc.HasValue)
                {
                    <div id="divShippedDate" style="display: inline-block;">@Html.EditorFor(model => model.ShippedDateUtc) &nbsp;@T("Admin.Orders.Shipments.ShippedDate.EnterUtc")</div>
                    <input type="submit" value="@T("Admin.Common.Edit")" onclick=" toggleShippedDate(true);return false; " id="btnEditShippedDate" class="adminButton" />
                    <input type="submit" value="@T("Admin.Common.Save")" id="btnSaveShippedDate" name="saveshippeddate" class="adminButton" onclick=" return confirm('@T("Admin.Common.AreYouSure")'); " />
                    <input type="submit" value="@T("Admin.Common.Cancel")" onclick=" toggleShippedDate(false);return false; " id="btnCancelShippedDate" class="adminButton" />
                }
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.DeliveryDate):
            </td>
            <td class="adminData">
                <span id="lblDeliveryDate">@Model.DeliveryDate</span>
                @if (Model.CanDeliver)
                {
                    <input type="submit" name="setasdelivered" value="@T("Admin.Orders.Shipments.DeliveryDate.Button")" id="setasdelivered" class="adminButton" />
                }
                @if (Model.DeliveryDateUtc.HasValue)
                {
                    <div id="divDeliveryDate" style="display: inline-block;">@Html.EditorFor(model => model.DeliveryDateUtc) &nbsp;@T("Admin.Orders.Shipments.DeliveryDate.EnterUtc")</div>
                    <input type="submit" value="@T("Admin.Common.Edit")" onclick=" toggleDeliveryDate(true);return false; " id="btnEditDeliveryDate" class="adminButton" />
                    <input type="submit" value="@T("Admin.Common.Save")" id="btnSaveDeliveryDate" name="savedeliverydate" class="adminButton" onclick=" return confirm('@T("Admin.Common.AreYouSure")'); " />
                    <input type="submit" value="@T("Admin.Common.Cancel")" onclick=" toggleDeliveryDate(false);return false; " id="btnCancelDeliveryDate" class="adminButton" />
                }
            </td>
        </tr>
    </table>
    <table class="adminContent">
        <tr>
            <td class="adminData">
                <strong>@T("Admin.Orders.Shipments.Products")</strong>
            </td>
        </tr>
        <tr>
            <td class="adminData">
                <table class="tablestyle" border="1" cellspacing="0" style="width: 100%; border-collapse: collapse;">
                    <col />
                    <col />
                    <col />
                    <col />
                    <col />
                    <thead>
                        <tr class="headerstyle">
                            <th align="center">
                                @T("Admin.Orders.Shipments.Products.ProductName")
                            </th>
                            <th align="center">
                                @T("Admin.Orders.Shipments.Products.SKU")
                            </th>
                            <th align="center">
                                @T("Admin.Orders.Shipments.Products.ItemWeight")
                            </th>
                            <th align="center">
                                @T("Admin.Orders.Shipments.Products.ItemDimensions")
                            </th>
                            <th align="center">
                                @T("Admin.Orders.Shipments.Products.QtyShipped")
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model.Items)
                        {
                            <tr>
                                <td style="width: 70%;">
                                    <div style="padding-left: 10px; padding-right: 10px; text-align: left;">
                                        <em><a href="@Url.Action("Edit", "Product", new { id = item.ProductId })">@item.ProductName</a></em>
                                        @if (!String.IsNullOrEmpty(item.AttributeInfo))
                                        {
                                            <br />
                                            @Html.Raw(item.AttributeInfo)
                                        }
                                    </div>
                                </td>
                                <td style="width: 15%;">
                                    <div style="padding-left: 10px; padding-right: 10px; text-align: left;">
                                        @item.Sku
                                    </div>
                                </td>
                                <td align="center" style="width: 10%;">
                                    @item.ItemWeight
                                </td>
                                <td align="center" style="width: 10%;">
                                    @item.ItemDimensions
                                </td>
                                <td align="center" style="width: 15%;">
                                    @item.QuantityInThisShipment
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </td>
        </tr>
    </table>
}
@Html.DeleteConfirmation("DeleteShipment", "shipment-delete")